<?php 
    class News_Cat_Model extends CI_Model
    {
        var $table = "db_news";
        public function __construct()
        {
            parent::__construct();
        }
        function add_news($data)
        {
            
            $data = array(
                'name_cat' =>$data['name_cat'],
                'order_news'    =>$data['order_news'],
                'active'   =>$data['active'], 
                'url'   =>$data['url'],                 
            );
            $this->db->set($data);
            
                if($this->db->insert($this->table)) return true; else return false;
            
        }
		 function update_news($id,$data)
        {
             $this->db->where("id_cat",$id);
            $data = array(
                'name_cat' =>$data['name_cat'],
                'order_news'    =>$data['order_news'],
                'active'   =>$data['active'], 
                'url'   =>$data['url'],                 
            );
            $this->db->set($data);
            
                if($this->db->update($this->table)) return true; else return false;            
        }
       function get_id($id)
        {          
                $this->db->where("id_cat",$id);
                return $this->db->get($this->table)->row();            
        }
		function show()
        {          
                return $this->db->get($this->table)->result();            
        }
        public function delete_id($id)
        {
			 $this->db->where("id_cat",$id);
            return $this->db->delete($this->table);
        }   
         function change_update_active($id,$data)
        {
            $this->db->where('id_cat',$id);
            $data = array(
            'active' => $data['active']
            );
            $this->db->set($data);
            if($this->db->update($this->table)) return true; else return false;
        }    
    }
?>